package com.yuntsg.subject_database.auxiliary;

import lombok.Data;

import java.sql.SQLException;
import java.util.*;

public class Test {
    public static void main(String[] args) throws SQLException {
        Map<String, List<JourInfo>> cnJourInfoMap = new HashMap<>();
        int id = 1;
        String jourName = "外国中小学教育（改名为：比较教育学报）";
        String jourIssn = "2096-7586".toLowerCase().replace(" ", "");
        JourInfo jourInfo = new JourInfo();
        if (jourName.indexOf("（改名为：") > 2 && jourName.endsWith("）")) {
            String jour = "外国中小学教育（改名为：比较教育学报）";
            jourName = jour.substring(0, jourName.indexOf("（改名为："));
            String oldName = jour.substring(jour.indexOf("（改名为：") + "（改名为：".length(), jour.length() - "）".length());
            jourInfo.getOld().add(oldName);
        }
        jourInfo.setAutoId(id);
        jourInfo.setCnName(jourName);
        jourInfo.setPIssn(jourIssn);
        cnJourInfoMap.compute(jourIssn, (k, v) -> {
            if (v == null) {
                v = Collections.synchronizedList(new ArrayList<>());
            }
            v.add(jourInfo);
            return v;
        });
        System.out.println(cnJourInfoMap);

        // main
    }

    @Data
    public static class JourInfo {
        private int autoId = 0;
        private String full = "";
        private String abb = "";
        private String iso = "";
        private String title = "";
        private String cnName = "";
        private String jourId = "";
        private Set<String> old = new HashSet<>();
        private String pIssn = "";
        private String eIssn = "";
        private String lIssn = "";
        private String cnIssn = "";
        private String url = "";
        private String other = "";
        private String data = "";
    }


// end
}
